Cancel Document
The Cancel Document API allows you to cancel a specific document by its unique identifier (documentId
). A reason for cancellation must be provided.
API URLs
Property | Value |
---|---|
Sandbox | https://malaysia-sandbox.complyance.io |
Production | https://malaysia-prod.complyance.io/ |
Endpoint | /cancelDocument |
Method | POST |
Headers
Header | Type | Description | Example | Conditionality |
---|---|---|---|---|
x-api-key | string | Your API key | 1aN3AQ8ZsggJ0UABAHXVB | Mandatory |
Content-Type | string | Set as application/json | application/json | Mandatory |
Request Body
The request body must be in JSON format.
Parameter | Type | Description | Example Value |
---|---|---|---|
documentId | string | Document reference number used by Supplier for internal tracking purpose. | E-INV-01 |
reason | string | The reason for cancelling the document. | Testing Cancellation |
Example Request Body
{
"documentId": "E-INV-01",
"reason": "Testing Cancellation"
}
Response
Success Response
HTTP Status Code: 200 OK
Response Body:
{
"uuid": "6FSDTHSGTW0CFCEBKVXVBFHJ10",
"status": "Cancelled",
"error": null
}
Error Responses
HTTP Status Code | Error Code | Description |
---|---|---|
400 | BAD_REQUEST | The provided input is invalid or missing fields. |
401 | UNAUTHORIZED | The API key is missing or invalid. |
500 | SERVER_ERROR | An internal server error occurred. |
Example Error Response:
{
"errorMessage": "Please check the field documentId"
}
Usage Example
- Shell
- JavaScript
- Python
- PHP
- Java
- Go
curl --location 'https://malaysia-prod.complyance.io//cancelDocument' \
--header 'Content-Type: application/json' \
--header 'x-api-key: 1aN3AQ8ZsggJ0UABAHXVB' \
--data '{
"documentId": "E-INV-01",
"reason": "Testing Cancellation"
}'
const headers = {
'Content-Type': 'application/json',
'x-api-key': '1aN3AQ8ZsggJ0UABAHXVB'
};
const body = {
documentId: "E-INV-01",
reason: 'Testing Cancellation'
};
fetch('https://malaysia-prod.complyance.io/cancelDocument', {
method: 'POST',
headers: headers,
body: JSON.stringify(body)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
url = 'https://malaysia-prod.complyance.io/cancelDocument'
headers = {
'Content-Type': 'application/json',
'x-api-key': '1aN3AQ8ZsggJ0UABAHXVB'
}
data = {
'documentId': 'E-INV-01',
'reason': 'Testing Cancellation'
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
<?php
$url = 'https://malaysia-prod.complyance.io/cancelDocument';
$headers = [
'Content-Type: application/json',
'x-api-key: 1aN3AQ8ZsggJ0UABAHXVB'
];
$data = [
'documentId' => 'E-INV-01',
'reason' => 'Testing Cancellation'
];
$options = [
'http' => [
'header' => $headers,
'method' => 'POST',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("https://malaysia-prod.complyance.io/cancelDocument");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("x-api-key", "1aN3AQ8ZsggJ0UABAHXVB");
con.setDoOutput(true);
String jsonInputString = "{\"documentId\": \"E-INV-01\", \"reason\": \"Testing Cancellation\"}";
try (OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
try (BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
}
}
package main
import (
"bytes"
"net/http"
"io/ioutil"
"fmt"
)
func main() {
url := "https://malaysia-prod.complyance.io/cancelDocument"
jsonData := []byte(`{"documentId": "E-INV-01", "reason": "Testing Cancellation"}`)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-api-key", "1aN3AQ8ZsggJ0UABAHXVB")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
Notes
- Ensure the
x-api-key
header contains a valid API key. - The
reason
parameter is required and should provide a clear explanation for the cancellation. - The API operates in a sandbox environment, so it is suitable for testing purposes.
Success Handling
The API may return the following success responses depending on the validation result or submission status:
Status Code | Description |
---|---|
200 | Success – The request was processed successfully. |
Error Handling
The API may return the following error responses depending on the validation result or request issues:
Error Code | Description |
---|---|
400 | Bad Request – Invalid data in the request. |
401 | Unauthorized – Invalid or missing API key. |
500 | Internal Server Error – Server encountered an error. |
Ensure that your request body and headers are correctly formatted to avoid errors.